Skip to content

Solution#218

Open
SerhiyDmytruk wants to merge 4 commits intomate-academy:masterfrom
SerhiyDmytruk:develop
Open

Solution#218
SerhiyDmytruk wants to merge 4 commits intomate-academy:masterfrom
SerhiyDmytruk:develop

Conversation

@SerhiyDmytruk
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Great job setting up the server and using streams for file compression! The core logic for handling the /compress endpoint is well-implemented. However, this requires a couple of changes to fully meet the task requirements.

  1. Incorrect compressed file extensions: The server currently appends the full compression type name (e.g., file.txt.gzip). The requirement specifies shorter extensions: .gz for gzip, .dfl for deflate, and .br for brotli. Consider creating a mapping to generate the correct filenames.

  2. Incomplete 404 handling: The server doesn't correctly handle all requests for non-existent endpoints. For example, a request for an existing file that isn't a defined route (like /package.json) will cause the client to hang. Your server should have a default 'catch-all' response that sends a 404 status for any unhandled request.

Please address these two issues to complete the task.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example


const readStream = fs.createReadStream(file.filepath);
const compressStream = createCompressionStream();
const outputFileName = `${file.originalFilename}.${compressionType}`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output filename extension does not match the requirements. The task specifies .gz for gzip compression and .dfl for deflate. Currently, the code appends the full compression type name (e.g., file.txt.gzip), which is incorrect. Consider creating a mapping from the compression type to the correct file extension.

Comment on lines +97 to +102
} else {
if (!fs.existsSync(realPath)) {
res.statusCode = 404;
res.end('Not Found');
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for handling 404 errors is not quite right. While it correctly returns a 404 for a path that doesn't exist on the filesystem, it fails to send any response for paths that do exist but aren't explicitly handled (e.g., /package.json if it exists). This will cause the client's request to hang and eventually time out. Any request that doesn't match a defined endpoint like / or /compress should receive a 404 response.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Excellent work implementing the 404 error handling! The server now correctly manages requests to non-existent endpoints. We are very close to completing the task, but one critical requirement is still outstanding.

The server is generating compressed files with incorrect extensions. According to the task description, the file extensions must be .gz for gzip and .dfl for deflate.

In src/createServer.js, please update your compressionMap to use the correct extensions. Once that's fixed, we'll be ready to approve this!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example


const compressionMap = {
gzip: {
extension: 'gzip',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the task description, the file extension for gzip compression should be .gz, not .gzip.

createStream: () => zlib.createGzip(),
},
deflate: {
extension: 'deflate',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The task requires the file extension for deflate compression to be .dfl, not .deflate.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Great work on the overall structure of your server! You've correctly handled routing, error conditions, and used streams effectively. I am approving this submission as an educational override to help you progress, but there is one critical fix needed to meet all the requirements. The server is currently generating compressed files with incorrect extensions. Specifically, gzip files are being saved with .gzip instead of .gz, and deflate files with .deflate instead of .dfl. To fix this, please update the compressionMap object in src/createServer.js to use the correct extensions. Keep up the great work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example


const compressionMap = {
gzip: {
extension: 'gzip',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the task description, the file extension for gzip compression should be .gz, not .gzip.

createStream: () => zlib.createGzip(),
},
deflate: {
extension: 'deflate',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The task description specifies that the file extension for deflate compression should be .dfl, not .deflate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants